(function($){
$.fn.extend({
	slide:function(opt,callback){
		
		if(!opt) var opt={};
		var timerID;
		var btnLeft = $("."+ opt.left);
		var btnRight = $("."+ opt.right);
		var _this=this.find("ul");
			liW=opt.li_w
			li_size=opt.li_size ? parseInt(opt.li_size,10) : parseInt(this.width()/liW,10)
			speed=opt.speed ? parseInt(opt.speed,10) : 500;
			timer=opt.timer 
		if(li_size==0) {li_size=1};
		var leftW=0-li_size*liW;
		
		function scrollLeft(){
				btnLeft.unbind("click",scrollLeft);
				btnRight.unbind("click",scrollRight);
				_this.animate({
					marginLeft:leftW
					},speed,"easeOutExpo",function(){ 
					for(i=1;i<=li_size;i++){
							_this.find("li:first").appendTo(_this);
					}
					_this.css({'margin-left':0});
					btnLeft.bind("click",scrollLeft); 
					btnRight.bind("click",scrollRight);
				});
		}
		
		function scrollRight(){
				btnLeft.unbind("click",scrollLeft);
				btnRight.unbind("click",scrollRight);
				for(i=1;i<=li_size;i++){
					_this.find("li:last").prependTo(_this);
				}
				_this.css({'margin-left':leftW});
				_this.animate({
					marginLeft:0
					},speed,"easeOutExpo",function(){
					btnLeft.bind("click",scrollLeft);
					btnRight.bind("click",scrollRight);
				});
		}
		
		function autoPlay(){
				if(timer) 
				timerID = window.setInterval(scrollLeft,timer);
		};
		
		function autoStop(){
				if(timer) 
				window.clearInterval(timerID);
		};
		
		_this.hover(autoStop,autoPlay).mouseout() 
		btnLeft.click( scrollLeft ).hover(autoStop,autoPlay);
		btnRight.click( scrollRight ).hover(autoStop,autoPlay);
	}       
})
})(jQuery);
